<template>
  <view class="content">
    <view class="form">
      <u--form labelPosition="left" ref="messageForm" :model="form">
        <u-form-item label="影片名称" prop="video_name">
          <u--input class="inline-input" v-model="form.video_name" border="bottom"></u--input>
        </u-form-item>
        <u-form-item label="姓名" prop="name">
          <u--input v-model="form.name" border="bottom"></u--input>
        </u-form-item>
        <u-form-item label="手机号码" prop="phone">
          <u--input v-model="form.phone" border="bottom"></u--input>
        </u-form-item>
        <view class="btn">
          <u-button @click="postForm" type="info" text="确定"></u-button>
        </view>
      </u--form>
    </view>
  </view>
</template>

<script>
import * as api from '@/api/api';
export default {
  data() {
    return {
      user: "",
      form: {
        video_name: "",
        name: "",
        phone: "",
      }
    };
  },
  onShow() {},
  methods: {
    async postForm() {
      if (!this.form.video_name) {
        uni.showToast({title: '影片名称为空', icon: 'none'});
        return;
      }
      if (!this.form.name) {
        uni.showToast({title: '用户为空', icon: 'none'});
        return;
      }
      if (!this.form.phone) {
        uni.showToast({title: '手机号码为空', icon: 'none'});
        return;
      }
      const {data: res} = await api.feedback(this.form);
      if(res.code == 1){
        uni.showToast({
          title: res.msg,
          icon: 'success',
          duration: 1000,
          success() {
            setTimeout(function() {
              uni.reLaunch({
                url: '/pages/index/index'
              })
            }, 1000)
          }
        });
      }else{
        uni.showToast({
          title: res.msg,
          icon: "none",
          duration: 1000
        });
      }
    }
  },
};
</script>

<style lang="scss" scoped>
.content {
  width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  .form {
    width: 690rpx;
    padding-top: 30rpx;
    .btn {
      margin-top: 60rpx;
    }
  }
}
</style>
